
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
    <title>JavaScript SOAP Client - DEMOS | GURU4.net</title>
	<style type="text/css">
		div.h { display: none; }
		div.s { display: block; margin: 10px; }
	</style>
	<script type="text/javascript" src="soapclient.js"></script>
	<script type="text/javascript">
	
	//var url = document.location.href.replace("demo.htm", "webservicedemo.asmx");
	
	// InitializeService
	function InitializeService()
	{
                // WSDLのURL
                var wsdlurl = "http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc?wsdl";
                // WebサービスのエンドポイントURL
                var endpointurl = "http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc/basic";
                // 実行するSOAPアクション
                var soapaction = "http://*****/ws/IRemittance/InitializeService";
                // SOAPアクションのパラメータ設定
		var pl = new SOAPClientParameters();
                pl.add("key", "*****");
                // 非同期処理でSOAPクライアント起動
		SOAPClient.invoke(wsdlurl, endpointurl, soapaction, pl, true, InitializeService_callBack);
	}
	function InitializeService_callBack(r,soapResponse)
	{
            alert(soapResponse.xml);
            if(r == null)
            {
		alert("Initialize failure.");
            }
            else
            {
		alert("Successful: " + r.Successful);
                alert("PrincipalClientName: " + r.CurrentSession.PrincipalClientName);
            }
	}
        // GetTransaction
	function GetTransaction()
	{
                // 同期処理でInitializeServiceを実行し、session情報取得
                var wsdlurl = "http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc?wsdl";
                var endpointurl = "http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc/basic";
                var soapaction = "http://*****/ws/IRemittance/InitializeService";
		var pl = new SOAPClientParameters();
                pl.add("key", "*****");
		var session = SOAPClient.invoke(wsdlurl, endpointurl, soapaction, pl, false);

                // 実行するSOAPアクション
                soapaction = "http://*****/ws/IBliRemittanceCore/GetTransaction";
                // SOAPアクションのパラメータ設定
                pl = new SOAPClientParameters();
                pl.add("transactionId", "*****");
                // SOAPアクションのパラメータ設定(session設定)
                // オブジェクトを設定する場合、以下のように記述
                var plSes = new SOAPClientParameters();
                plSes.add("Channel",session.CurrentSession.Channel);
                plSes.add("ExternalApplicationId",session.CurrentSession.ExternalApplicationId);
                plSes.add("ExternalUserId",session.CurrentSession.ExternalUserId);
                plSes.add("MembershipObtained",session.CurrentSession.MembershipObtained);
                plSes.add("PrincipalClient",session.CurrentSession.PrincipalClient);
                plSes.add("PrincipalClientName",session.CurrentSession.PrincipalClientName);
                plSes.add("PrincipalLogin",session.CurrentSession.PrincipalLogin);
                plSes.add("PrincipalProfile",session.CurrentSession.PrincipalProfile);
                plSes.add("Service",session.CurrentSession.Service);
                plSes.add("SessionId",session.CurrentSession.SessionId);
                pl.add("session", plSes);
                // 非同期処理でSOAPクライアント起動
                SOAPClient.invoke(wsdlurl, endpointurl, soapaction, pl, true, GetTransaction_callBack);
	}
	function GetTransaction_callBack(r,soapResponse)
	{
            alert(soapResponse.xml);
            if(r == null)
            {
		alert("No transaction found.");
            }
            else
            {
		alert("Remitter.FirstName: " + r.Remitter.FirstName);
            }
	}
	
	// utils
	function toggle(id) 
	{
		var d = document.getElementById(id);
		if(d != null)
			d.className = (d.className == "h") ? "s" : "h"; 
	} 

	</script>
</head>
<body>
    <form id="frmDemo" name="frmDemo" action="" method="post">
    <div>
        <a name="d0"></a>
        <h2>DEMO 0: "InitializeService"</h2>
        <p>The simplest example you can imagine (but maybe not the most fanciful...):</p>
        <input type="button" value="Say &quot;InitializeService&quot;" onclick="InitializeService();" />
        <p><b>&nbsp;&#187;&nbsp;</b><a href="javascript:toggle('demo0');">Show / hide sample source code</a></p>
        <div id="demo0" class="h">
			<fieldset>
				<legend>Client (javascript)</legend>
				<kbd>
					function InitializeService()<br />
					{<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// WSDLのURL<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var wsdlurl = &quot;http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc?wsdl&quot;;<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// WebサービスのエンドポイントURL<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var endpointurl = &quot;http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc/basic&quot;;<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// 実行するSOAPアクション<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var soapaction = &quot;http://*****/ws/IRemittance/InitializeService&quot;;<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// SOAPアクションのパラメータ設定<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;var pl = new SOAPClientParameters();<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;pl.add(&quot;key&quot;, &quot;15c0dcb580d24cdbbd77d33ff966a1be&quot;);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// 非同期処理でSOAPクライアント起動<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;SOAPClient.invoke(wsdlurl, endpointurl, soapaction, pl, true, InitializeService_callBack);<br />
					}<br />
					function InitializeService_callBack(r,soapResponse)<br />
					{<br />
					&nbsp;&nbsp;&nbsp;&nbsp;alert(soapResponse.xml);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;if(r == null)<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;No user found.&quot;);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;else<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;Successful: &quot; + r.Successful);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;PrincipalClientName: &quot; + r.CurrentSession.PrincipalClientName);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
					}
				</kbd>
			</fieldset>
        </div>
                <h2>DEMO 1: "GetTransaction"</h2>
        <p>The simplest example you can imagine (but maybe not the most fanciful...):</p>
        <input type="button" value="Say &quot;GetTransaction&quot;" onclick="GetTransaction();" />
        <p><b>&nbsp;&#187;&nbsp;</b><a href="javascript:toggle('demo1');">Show / hide sample source code</a></p>
        <div id="demo1" class="h">
			<fieldset>
				<legend>Client (javascript)</legend>
				<kbd>
					function GetTransaction()<br />
					{<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// 同期処理でInitializeServiceを実行し、session情報取得<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var wsdlurl = &quot;http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc?wsdl&quot;;<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var endpointurl = &quot;http://*****/RemittanceService/Arias.Jp.Api.Remittance.svc/basic&quot;;<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var soapaction = &quot;http://*****/ws/IRemittance/InitializeService&quot;;<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;var pl = new SOAPClientParameters();<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;pl.add(&quot;key&quot;, &quot;*******&quot;);<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;var session = SOAPClient.invoke(wsdlurl, endpointurl, soapaction, pl, false);<br />
                                        <br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// 実行するSOAPアクション<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;soapaction = &quot;http://*****/ws/IBliRemittanceCore/GetTransaction&quot;;<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// SOAPアクションのパラメータ設定<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;pl = new SOAPClientParameters();<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;pl.add(&quot;transactionId&quot;, &quot;******&quot;);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// SOAPアクションのパラメータ設定(session設定)<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// オブジェクトを設定する場合、以下のように記述<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;var plSes = new SOAPClientParameters();<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;Channel&quot;,session.CurrentSession.Channel);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;ExternalApplicationId&quot;,session.CurrentSession.ExternalApplicationId);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;ExternalUserId&quot;,session.CurrentSession.ExternalUserId);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;MembershipObtained&quot;,session.CurrentSession.MembershipObtained);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;PrincipalClient&quot;,session.CurrentSession.PrincipalClient);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;PrincipalClientName&quot;,session.CurrentSession.PrincipalClientName);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;PrincipalLogin&quot;,session.CurrentSession.PrincipalLogin);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;PrincipalProfile&quot;,session.CurrentSession.PrincipalProfile);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;Service&quot;,session.CurrentSession.Service);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;plSes.add(&quot;SessionId&quot;,session.CurrentSession.SessionId);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;pl.add(&quot;session&quot;, plSes);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;// 非同期処理でSOAPクライアント起動<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;SOAPClient.invoke(wsdlurl, endpointurl, soapaction, pl, true, GetTransaction_callBack);<br />
					}<br />
					function GetTransaction_callBack(r,soapResponse)<br />
					{<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;alert(soapResponse.xml);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;if(r == null)<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;No transaction found.&quot;);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;else<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
		                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;Remitter.FirstName: &quot; + r.Remitter.FirstName);<br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
					}
				</kbd>
			</fieldset>
        </div>
    </div>
    </form>
</body>
</html>